import { onBeforeMount, onMounted, onBeforeUpdate, onUpdated, onActivated, onDeactivated, onBeforeUnmount, onUnmounted } from 'vue';

// 调试生命周期用
export const useLifecycle = (name: string) => {
  onBeforeMount(() => {
    console.log('【' + name + '】   ' + new Date() + ' onBeforeMount !');
  });
  onMounted(() => {
    console.log('【' + name + '】   ' + new Date() + ' onMounted !');
  });
  onBeforeUpdate(() => {
    console.log('【' + name + '】   ' + new Date() + ' onBeforeUpdate !');
  });
  onUpdated(() => {
    console.log('【' + name + '】   ' + new Date() + ' onUpdated !');
  });
  onActivated(() => {
    console.log('【' + name + '】   ' + new Date() + ' onActivated !');
  });
  onDeactivated(() => {
    console.log('【' + name + '】   ' + new Date() + ' onDeactivated !');
  });
  onBeforeUnmount(() => {
    console.log('【' + name + '】   ' + new Date() + ' onBeforeUnmount !');
  });
  onUnmounted(() => {
    console.log('【' + name + '】   ' + new Date() + ' onUnmounted !');
  });
};
